package io.sage.common.utils;

import java.util.UUID;

/**
 * 生成UUID
 */
public class UUIDLongGenerator {

	private static int count = 10000;
	private static int step = 0;

	/**
	 * 生成18位长整形数字
	 * 
	 * @return
	 */
	public static synchronized long generateId() {

		if (count > 99999) {
			step++;
			count = 10000;
		}
		return Long.parseLong("" + (System.currentTimeMillis() + step) + (count++));
	}

	/**
	 * 生成32位的uuid
	 * @author :zhangchunlei 2018/1/9
	 * @return :java.lang.String
	 */
	public static synchronized String getUUID() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}

	public static void main(String[] args) {
		System.out.println(UUID.randomUUID().toString());
	}
}
